package com.jiezuo.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiezuo.auth.entity.PermissionApiField;
import com.jiezuo.auth.mapper.PermissionApiFieldMapper;
import com.jiezuo.auth.service.PermissionApiFieldService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
* @description   数据权限API拦截字段
* @author        庞留杰
* @date          2022/02/16 09:33
* @version       V1.0
**/
@Transactional
@Slf4j
@Service
public class PermissionApiFieldServiceImpl extends ServiceImpl<PermissionApiFieldMapper, PermissionApiField> implements PermissionApiFieldService{

    @Override
    public IPage<PermissionApiField> findPage(Page initMpPage, PermissionApiField permissionApiField) {
        QueryWrapper<PermissionApiField> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete","0");
        return this.page(initMpPage,queryWrapper);
    }

    @Override
    public List<PermissionApiField> findList(PermissionApiField permissionApiField) {
        QueryWrapper<PermissionApiField> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete","0");
        List<PermissionApiField> list = this.list(queryWrapper);
        return list;
    }

    @Override
    public PermissionApiField findById(String id) {
        return this.getById(id);
    }

    @Override
    public boolean add(PermissionApiField permissionApiField) {
        return this.save(permissionApiField);
    }

    @Override
    public boolean update(PermissionApiField permissionApiField) {
        return this.updateById(permissionApiField);
    }

    @Override
    public boolean delete(String id) {
        PermissionApiField permissionApiField = new PermissionApiField();
        permissionApiField.setId(id);
        permissionApiField.setIs_delete("1");
        return this.updateById(permissionApiField);
    }
}
